//
//  HXMainViewController.m
//  NewProject
//
//  Created by Livespro on 2017/5/5.
//  Copyright © 2017年 FZ. All rights reserved.
//

#import "HXMainViewController.h"

#import "HXChatListViewController.h"
#import "HXFriendListViewController.h"
#import "HXGroupListViewController.h"

@interface HXMainViewController ()<UITabBarDelegate,UITabBarControllerDelegate>

@end

@implementation HXMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.fd_prefersNavigationBarHidden = YES;
    
    HXChatListViewController *chatList = [[HXChatListViewController alloc] init];
    [self addChildVC:chatList title:@"消息" imageName:@"tab_notice_nor" selectImage:@"tab_notice_sel"];
    
    HXFriendListViewController *friendList = [[HXFriendListViewController alloc] init];
    [self addChildVC:friendList title:@"好友" imageName:@"tab_friend_nor" selectImage:@"tab_friend_sel"];
    
    HXGroupListViewController *groupList = [[HXGroupListViewController alloc] init];
    [self addChildVC:groupList title:@"群组" imageName:@"tab_group_nor" selectImage:@"tab_group_sel"];
    
    [self.tabBar setBackgroundImage:[UIImage new]];
    [self.tabBar setShadowImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"cccccc" alpha:.5]]];
    
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(numChange:) name:@"TabCartNumGo" object:nil];

}

/**
 *  添加子视图
 */
- (void)addChildVC:(BaseViewController *)ChildVC title:(NSString *)title imageName:(NSString *)imageName selectImage:(NSString *)selectImage
{
    //设置文本
    ChildVC.tabBarItem.title = title;
    ChildVC.naviStand.title = title;
    //设置默认图标
    ChildVC.tabBarItem.image = [UIImage imageNamed:imageName];
    //设置tabBar
    self.tabBar.tintColor = naviColor;
    //设置选中图标
    ChildVC.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];
    //设置导航控制器
    MainNaviController *ChildNVC = [[MainNaviController alloc] initWithRootViewController:ChildVC];
    //改变导航条的颜色
    ChildNVC.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
    
    //将设置好的视图控制器添加到tabBarController
    [self addChildViewController:ChildNVC];
}

@end
